import cPickle



def dump_model(model, datafile):
    "dump a model to a file"
    file =  open(datafile, 'wb')
    cPickle.dump(model, file, cPickle.HIGHEST_PROTOCOL)
    pass

def read_model(datafile):
    "read a model from a file"
    file =  open(datafile, 'rb')
    model = cPickle.load(file)
    return model